import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: happyiu
 * Date: 2021-10-29
 * Time: 17:22
 */
public class TestDemo {
    public static void main1(String[] args) {
        int day = 1;
        switch(day) {
            case 1:
                System.out.println("星期一");
            case 2:
                System.out.println("星期二");
                break;
        }
    }


    public static void main2(String[] args) {
        int num = 1;
        switch(num) {
            case 1:
                System.out.println("hehe");
                break;
            case 2:
                System.out.println("haha");
                break;
        }
    }

    public static void main3(String[] args) {
        // 例如: 如果 num 的值在 10 到 20 之间, 就打印 hehe
        // 这样的代码使用 if 很容易表达, 但是使用 switch 就无法表示.
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        if (num > 10 && num < 20) {
            System.out.println("hehe");
        }
    }

    public static void main4(String[] args) {
        int x = 1;
        int y = 1;
        switch(x) {
            case 1:
                switch(y) {
                    case 1:
                        System.out.println("hehe");
                        break;
                }
                break;
            case 2:
                System.out.println("haha");
                break;
        }
    }

    public static void main(String[] args) {
        int num = 1;
        int sum = 0;
            // 外层循环负责求阶乘的和
        while (num <= 5) {
            int factorResult = 1;
            int tmp = 1;
            // 里层循环负责完成求阶乘的细节.
            while (tmp <= num) {
                factorResult *= tmp;
                tmp++;
            }
            sum += factorResult;
            num++;
        }
        System.out.println("sum = " + sum);
    }

}
